#include "System.h"
#include "Exceptions.h"

namespace BPL
{

EntityManager* System::entityManager = 0;

void System::addEntity(int ent)
{
	if(!entityManager->hasEntity(ent))
		return;

    mpt_entitiesID.insert(ent);
	entityManager->getEntity(ent)->addSystem(this);
}

void System::deleteEntity(int ent)
{
    std::set<int>::iterator itr = mpt_entitiesID.find(ent);
	if(itr != mpt_entitiesID.end())
	{
		mpt_entitiesID.erase(itr);
#ifdef DEFINE_MODE
		Logger::log("delete from System");
#endif
	}
}

void System::clearEntities()
{
	mpt_entitiesID.clear();
}

bool System::hasEntity(int ent) const
{
	return true;
}

void System::attachApp(sf::RenderWindow* app)
{
    mpt_app = app;
    Assert(mpt_app != NULL);
}

void System::setParent(State* parent)
{
	mpt_parent = parent;
}

}
